import builder.QueryBuilder;
import domain.Address;
import domain.Student;
import domain.Vehicle;


public class StartUp {
	public static void main(String[] args) {		
		System.out.println(QueryBuilder.createSelectQuery()
					.selectAll()
					//.select(Student.NAME, Student.HEIGHT, Student.ADDRESS_ID, Vehicle.LICENSE_PLATE)
					.from(Student.TABLE)
					.join(Address.TABLE, Address.ID, Student.ADDRESS_ID)
					.join(Vehicle.TABLE, Vehicle.STUDENT_ID, Student.ID)
					.where(Student.NAME).like("%MOERM_N")
					.where(Student.WEIGHT).between("5", "10")
					.where(Address.CITY).in("Hulste", "Izegem", "Ingelmunster")
					/*
					 *
					 * If you have a list of items, you can use
					 * 		List<String> cities = new ArrayList<>(Arrays.asList("Hulste", "Izegem", "Ingelmunster"));
					 * 		
					 * 		.where(Address.CITY).in(cities.toArray(new String[]{}))
					 */
					.build());
		
		System.out.println(QueryBuilder.createSelectQuery()
				.selectDistinct(Student.NAME, Student.HEIGHT)
				.from(Student.TABLE)
				.where(Student.HEIGHT).lessThan("100")
				.orderByAscending(Student.NAME)
                .orderByDescending(Student.HEIGHT)
				.build());
		
		System.out.println(QueryBuilder.createInsertQuery()
				.insert(Student.TABLE, Student.NAME, Student.HEIGHT, Student.WEIGHT)
				.values("Simon","176","90")
				.build());
		
		System.out.println(QueryBuilder.createUpdateQuery()
				.update(Student.TABLE)
				.set(Student.NAME, "Simon")
				.set(Student.HEIGHT, "176")
				.set(Student.WEIGHT, "90")
				.where(Student.ID).equals("1")
				.where(Student.HEIGHT).greaterThanOrEquals("160")
				.build());
		
		System.out.println(QueryBuilder.createDeleteQuery()
				.delete(Student.TABLE)
				.where(Student.ID).equals("1")
				.where(Student.NAME).like("S%")
				.build());
	}
}
